package syerit.core.utils
{
	import flash.display.Stage;
	import flash.events.KeyboardEvent;
	
	public class ObjectManipulator
	{
		public function ObjectManipulator()
		{
		}
		
		private static var src:Object;
		private static var speed:Number;
		
		public static function manipulate(stage:Stage,obj:Object,step:Number = 1):void
		{
			src = obj;
			speed = step;
			
			stage.addEventListener(KeyboardEvent.KEY_DOWN,onkey);
		}
		
		private static function onkey(e:KeyboardEvent):void
		{
			//trace(e.keyCode);
			//var src:Object3D = regForm;
			switch(e.keyCode)
			{
				case 87:
				{
					src.z+=speed;
					break;
				}
				case 83:
				{
					src.z-=speed;
					break;
				}
				case 65:
				{
					src.x-=speed;
					break;
				}
				case 68:
				{
					src.x+=speed;
					break;
				}
				case 39:
				{
					src.scaleX+=.1;
					src.scaleY+=.1;
					src.scaleZ+=.1;
					break;
				}
				case 37:
				{
					src.scaleX-=.1;
					src.scaleY-=.1;
					src.scaleZ-=.1;
					break;
				}
				case 38:
				{
					src.y+=speed;
					break;
				}
				case 40:
				{
					src.y-=speed;
					break;
				}
				case 100:
				{
					src.rotationY-=speed;
					break;
				}
				case 102:
				{
					src.rotationY+=speed;
					break;
				}
				
				case 104:
				{
					src.rotationX+=speed;
					break;
				}
				case 98:
				{
					src.rotationX-=speed;
					break;
				}
				
				case 99:
				{
					src.rotationZ+=speed;
					break;
				}
				case 97:
				{
					src.rotationZ-=speed;
					break;
				}
				
			}
			
			trace("x:"+src.x,"z:"+src.z,"y:"+src.y,"rotY:"+src.rotationY,"rotX:"+src.rotationX,"rotZ:"+src.rotationZ);
			
		}

	}
}